package controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import biz.WordchildBiz;
import entity.Wordchild;
@Controller
public class WordchildController extends MultiActionController {
	private WordchildBiz wordchildBiz;
	
	@RequestMapping("/wordchild/findAll.do")
	@ResponseBody
	public String findAll(){
		Map<String, Object> map = new HashMap<String, Object>();
		List<Wordchild> list = wordchildBiz.findAll();
		Integer count = list.size();
        map.put("rows",list);
        map.put("total",count);
        JSONObject jsons = JSONObject.fromObject(map);
        return jsons.toString();
	}
	
	@RequestMapping("/wordchild/findByWordid.do")
	@ResponseBody
	public String findByWordid(Integer id){
		List<Wordchild> list = wordchildBiz.findByWordid(id);
        JSONArray jsons = JSONArray.fromObject(list);
        return jsons.toString();
	}
	
	
	public WordchildBiz getWordchildBiz() {
		return wordchildBiz;
	}

	public void setWordchildBiz(WordchildBiz wordchildBiz) {
		this.wordchildBiz = wordchildBiz;
	}
	
	
}
